<template>
  <div>
    <!-- 弹窗内容区域 -->
    <div class="huxing" >
      <p style="font-size: 15px; margin-left: 10px">户型</p>
      <van-row type="flex">
        <div class="frist">
          <van-col span="8" v-for="(item, index) in findList[0]" :key="index">
            <div :class="['channel-item van-hairline--surround',list.includes(item.value)?'green':'']" @click="hxFn(item.value,index)">
              {{ item.label }}
            </div>
          </van-col>
        </div>
      </van-row>
      <p style="font-size: 15px; margin-left: 10px">朝向</p>
      <van-row type="flex">
        <div class="frist">
          <van-col span="8" v-for="(item, index) in findList[1]" :key="index">
            <div :class="['channel-item van-hairline--surround',list.includes(item.value)?'green':'']" @click="hxFn(item.value,index)">
              {{ item.label }}
            </div>
          </van-col>
        </div>
      </van-row>
      <p style="font-size: 15px; margin-left: 10px">楼层</p>
      <van-row type="flex">
        <div class="frist">
          <van-col span="8" v-for="(item, index) in findList[2]" :key="index">
            <div :class="['channel-item van-hairline--surround',list.includes(item.value)?'green':'']" @click="hxFn(item.value,index)">
              {{ item.label }}
            </div>
          </van-col>
        </div>
      </van-row>
      <p style="font-size: 15px; margin-left: 10px">房屋亮点</p>
      <van-row type="flex">
        <div class="frist">
          <van-col span="8" v-for="(item, index) in findList[3]" :key="index">
            <div :class="['channel-item van-hairline--surround',list.includes(item.value)?'green':'']" @click="hxFn(item.value,index)">
              {{ item.label }}
            </div>
          </van-col>
        </div>
      </van-row>
         <!-- 筛选区的确认与取消 -->
         <div class="eareConfirm">
           <button class="concel" @click="checksstyleConcel">返回</button><button class="confirm" @click="checksstyleClick">确认</button>
         </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['findList'],
  data () {
    return {
      list: [], // 筛选的数组
      shows: true
    }
  },
  methods: {
    // 选择需要筛选的条件
    hxFn (val, index) {
      console.log(index)
      // 筛选出需要的索引
      const i = this.list.indexOf(val)
      i === -1 ? this.list.push(val) : this.list.splice(i, 1)
      console.log(val)
      console.log(this.list.join(','))
    },
    // 返回
    checksstyleConcel () {
      this.list = ''
      this.$emit('open')
    },
    // 确认
    checksstyleClick () {
      // 使用自定义事件父传子
      console.log(1)
      this.$emit('open', this.list.join(','))
    }
  }
}
</script>

<style lang="less" scoped>
/* // 筛选页样式 */
.frist {
  width: 250px;
  border-bottom: 1px solid #e5e5e5;
  margin-left: 50px;
  margin-top: 6px;
  padding-bottom: 9px;
}
.channel-item {
  height: 28px;
  width: 60px;
  margin: 0 15px 15px 0px;
  border: 1px solid #ddd;
  border-radius: 3px;
  line-height: 28px;
  text-align: center;
  font-size: 12px;
  color: #888;
}
.green{
background-color: #defaef;
color: #21b97a;
border: 1px solid #21b97a;
}
// 筛选区的清除与确认
.eareConfirm{
    position: sticky;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 50px;
    // background-color: rgb(197, 86, 86);
    z-index: 100000;
    display: flex;
    font-size: 16px;
    color: #fff;
    .confirm{
      width: 60%;
      background-color: #43b978;
      border: none;
    }
    .concel{
    flex: 1;
    border: none;
    background-color: #fff;
    color: black;
    }
  }
</style>
